package com.cryann.mqttserver.repository;

import com.cryann.mqttserver.modle.Topic;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

/**
 * @author cRyann
 * @date 2018/12/6 0006 17:22
 * @description:
 */
public interface TopicRepository extends JpaRepository<Topic, String> {
    Optional<Topic> findByTopicName(String string);

    List<Topic> findByTopicNameOrTopicNameOrTopicName(String topic, String f1, String f2);

    @Query(value = "SELECT * FROM topic WHERE topic_name REGEXP ?1", nativeQuery = true)
    List<Topic> findTopicByRegex(String regex);
}
